Skip to content

Conversation

@kunnaall04
Copy link

(Explain how this PR changes mypy.)

Kunal Sali and others added 7 commits January 20, 2026 00:28
…us operator detection

- Add missing imports: ConditionalExpr, GeneratorExpr, ListComprehension, SetComprehension, DictionaryComprehension, SliceExpr
- Handle ConditionalExpr (ternary operator) to check cond, if_expr, and else_expr
- Handle SliceExpr to check begin_index, end_index, and stride
- Handle GeneratorExpr and comprehensions (ListComprehension, SetComprehension, DictionaryComprehension)
- Ensures comprehensive detection of assignment expressions (walrus operators) in all nested expression contexts
- Fixes CI failures related to incomplete expression type handling
- Fix DictExpr iteration: iterate over items directly (items is list[tuple[Expression | None, Expression]])
- Fix IndexExpr: remove unnecessary None check since index is always Expression, not Optional
- Addresses mypy self-check failures:
  - DictExpr has no attribute 'values'
  - Unreachable code after return statement
  - Type mismatch in zip iteration
@kunnaall04 kunnaall04 force-pushed the fix-callable-any-narrowing branch from 81ce477 to a0eb6ad Compare February 7, 2026 19:30
@github-actions

This comment has been minimized.

@kunnaall04 kunnaall04 force-pushed the fix-callable-any-narrowing branch 2 times, most recently from 2561998 to c8ef1d9 Compare February 10, 2026 18:34
@github-actions

This comment has been minimized.

@kunnaall04 kunnaall04 force-pushed the fix-callable-any-narrowing branch from c8ef1d9 to 63b8f98 Compare February 10, 2026 19:26
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
+ aiohttp_devtools/runserver/config.py:210: error: Item "Application" of "Callable[..., Any] | Application" has no attribute "__defaults__"  [union-attr]
+ aiohttp_devtools/runserver/config.py:215: error: Unused "type: ignore" comment  [unused-ignore]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/typing/pandas.py:186: error: Incompatible types in assignment (expression has type "function", variable has type "Callable[..., Any]")  [assignment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant